import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home'
import Index from '../views/Index'
import Product from '../views/Product'
import Detail from '../views/Detail'
import Cart from '../views/Cart'
import Order from '../views/Order'
import OrderConfirm from '../views/OrderConfirm'
import OrderList from '../views/OrderList'
import OrderPay from '../views/OrderPay'
import Alipay from "../views/Alipay";

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'home',
        component: Home,
        redirect:'/index',
        // 子路由
        children: [
            {
                path: '/index',
                name: 'index',
                component: Index
            }, {
                path: '/product/:id',
                name: 'product',
                component: Product
            }, {
                path: '/detail/:id',
                name: 'detail',
                component: Detail
            },
        ]
    },
    {
        path: '/cart',
        name: 'cart',
        component: Cart
    },
    {
        path: '/order',
        name: 'order',
        component: Order,
        // 子路由
        children: [
            {
                path: 'list',
                name: 'order-list',
                component: OrderList
            }, {
                path: 'confirm',
                name: 'order-confirm',
                component: OrderConfirm
            }, {
                path: 'pay',
                name: 'order-pay',
                component: OrderPay
            },{
                path: 'alipay',
                name: 'alipay',
                component: Alipay
            },
        ]
    }
]

const router = new VueRouter({
    routes
})

export default router
